<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <LINK rel="Bookmark" href="/favicon.ico">
    <LINK rel="Shortcut Icon" href="/favicon.ico"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/Public/static/html5.js"></script>
    <script type="text/javascript" src="/Public/static/respond.min.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/PIE_IE678.js"></script>
    <![endif]-->
    <link href="/Public/Admin/css/manager/H-ui.min.css" rel="stylesheet" type="text/css"/>
    <link href="/Public/Admin/css/manager/H-ui.admin.css" rel="stylesheet" type="text/css"/>
    <link href="/Public/Admin/css/skin/default/skin.css" rel="stylesheet" type="text/css"/>
    <link href="/Public/Admin/css/manager/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css"/>
    <link href="/Public/Admin/css/common.css" rel="stylesheet" type="text/css"/>
    <link href="/Public/Admin/css/application.css" rel="stylesheet" type="text/css"/>
    <title>后台</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <script type="text/javascript" src="/Public/static/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="/Public/static/layer/layer.js"></script>
    <script type="application/javascript" src="/Public/static/form/jquery.validate.min.js"></script>
    <script type="application/javascript" src="/Public/static/form/localization/messages_zh.min.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/H-ui.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/H-ui.admin.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/common.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/jquery.raty.min.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/timer.js"></script>
    <script type="text/javascript">
        $(function () {
            //搜索功能
            $("#search_layer").click(function () {
                layer.closeAll();
                layer.open({
                    type: 2,
                    title: 'id搜索工具',
                    shadeClose: true,
                    shade: false,
                    maxmin: true, //开启最大化最小化按钮
                    area: ['650px', '550px'],
                    content: '<?php echo U("/Admin/Doctor/NRDoctor/search");?>'
                });
            });
        })
    </script>
</head>
<div class="pd-20">

        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <div class="cf">
                <a class="btn btn-primary radius" id="moreback"  _href="<?php echo U('/Admin/Usercenter/Usercenter/morebackname',array('key'=>'ADDMOREBACKNAME'));?>" onclick="morebackname()">加入黑名单</a>
                <a class="btn btn-primary radius" id="moretags" _href="<?php echo U('/Admin/Usercenter/Usercenter/moretags',array('key'=>'ADDMORETAGS'));?>" onclick="moretags()">添加标签</a>
                <input type="text" id="seach" name="seach"  ><input id="shousuo" type="button" value="搜索">
            </div>
        </div>
    <!-- 数据列表 -->
    <div class="mt-20">
        <div class="data-table table-striped">
            <div class="data-table table-striped">
                <table class="table table-border table-bordered table-bg table-sort">
                    <thead>
                    <tr class="text-c">
                        <th><input type="checkbox" name="check" id="check" onclick="allcheck();"></th>
                        <th>用户昵称</th>
                        <th>手机号</th>
                        <th>注册时间</th>
                        <th>最后登录时间</th>
                        <th>标签</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                   <?php if(is_array($userlist)): $i = 0; $__LIST__ = $userlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr class="text-c">
                            <td><input type="checkbox" name="tg" id="<?php echo ($vo["id"]); ?>" value="<?php echo ($vo["id"]); ?>"></td>
                            <td><?php echo ($vo["nickname"]); ?></td>
                            <td><?php echo ($vo["mobile"]); ?></td>
                            <td ><?php echo ($vo["register_time"]); ?></td>
                            <td ><?php echo ($vo["register_time"]); ?></td>
                            <td >vip会员</td>
                            <td>

                                <!--<a title="标签" href="javascript:void(0);" onclick="tags(<?php echo ($vo["id"]); ?>)"
                                   class="fontblue">打标签</a>-->

                                <a class="confirm ajaxget fontblue" onclick="resetpassword(<?php echo ($vo["id"]); ?>)" title="重置密码" href="javascript:" refresh="true">重置密码</a>
                                <a class="confirm ajaxget fontblue" onclick ="addbackname(<?php echo ($vo["id"]); ?>)" title="加入黑名单" href="javascript:" refresh="true">加入黑名单</a>
                            </td>
                        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                    </tbody>
                </table>
            </div>
            <!-- 分页 -->
            <div class="page">
                <?php echo ($_page); ?>
            </div>
        </div>
    </div>
</div>

<div id="showdiv" _href="<?php echo U('/Admin/Usercenter/Usercenter/resetpassword',array('key'=>'RESETPASSWORD'));?>"  style="display:none; height:300px;text-align:center;">

    <input type="password" name="password" id="password">
    <input type="hidden" name="userid" id="userid" value="">
    <div class="UploadTxBox-btnbox">
        <button class="btn btn-red"  type="button" id="submit_crop">提交</button>
        <button class="btn btn-white mlt10 closeDialogbtn" type="button">取消</button>
    </div>
</div>
<div id="backdiv" _href="<?php echo U('/Admin/Usercenter/Usercenter/addbackname',array('key'=>'ADDBACKNAME'));?>"  style="display:none; height:100px;text-align:center;">
    <input type="hidden" name="usersid" id="usersid" value="">
    <div class="UploadTxBox-btnbox">
        <button class="btn btn-red"  type="button" id="submit_back">是</button>
        <button class="btn btn-white mlt10 closeDialogbtn" type="button">否</button>
    </div>
</div>
<div id="tagsdiv" _href="<?php echo U('/Admin/Usercenter/Usercenter/addtags',array('key'=>'ADDUSERTAGS'));?>"  style="display:none; height:200px;text-align:center;">
    <div class="UploadTxBox-btnbox ">
        <?php if(is_array($alltags)): $i = 0; $__LIST__ = $alltags;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$p): $mod = ($i % 2 );++$i; echo ($p["id"]); ?><input type="checkbox" name="tags"  value="<?php echo ($p["id"]); ?>"><?php echo ($p["name"]); ?></br><?php endforeach; endif; else: echo "" ;endif; ?>
        <button class="btn btn-red"  type="button" id="submit_tags">确定</button>
        <button class="btn btn-white mlt10 closeDialogbtn" type="button">取消</button>
    </div>
</div>
<input type="hidden" name="id" id="id" value="">

<script>
    $(".closeDialogbtn").click(function () {
        layer.closeAll();
    });
    function resetpassword(id){
        $("#userid").val(id);
            layer.open({
                type: 1,
                skin: 'layui-layer-yuan', //样式类名
                closeBtn: 1, //不显示关闭按钮
                shadeClose: true, //开启遮罩关闭
                shade: [0.5],
                area: '580px',
                title: "密码重置",
                content: $('#showdiv')
            });

        $("#submit_crop").click(function () {
            var password  =$("#password").val();
            var userid = $("#userid").val();
            $.ajax({
                type: 'post',
                data: {"userid":userid,"password":password},
                url: $("#showdiv").attr('_href'),
                dataType: 'text',
                success: function (data) {
                    if(data=='ok'){
                        alert('修改成功');
                        layer.closeAll();
                    }else{
                        alert('修改失败');
                        layer.closeAll();
                    }
                }
            })
        })
    }

    function addbackname(id){

        if(window.confirm('你确定把此用户添加到黑名单列？')){
            //alert("确定");
            var url = "<?php echo U('/Admin/Usercenter/Usercenter/addbackname',array('key'=>'ADDBACKNAME'));?>"
            $.ajax({
                type: 'post',
                data: {"userid":id},
                url: url,
                dataType: 'text',
                success: function (data) {
                    if(data=='ok'){
                        alert('修改成功');
                        //layer.closeAll();
                    }else{
                        alert('修改失败');
                        //layer.closeAll();
                    }
                }
            })

            //return true;
        }else{
            //alert("取消");
            return false;
        }
    }
    /*打标签*/
   function tags(id){
       $("#id").val(id);
       layer.open({
           type: 1,
           skin: 'layui-layer-yuan', //样式类名
           closeBtn: 1, //不显示关闭按钮
           shadeClose: true, //开启遮罩关闭
           shade: [0.5],
           area: '180px',
           title: "添加标签",
           content: $('#tagsdiv')
       });
       $("#submit_tags").click(function () {
           var usersid = $("#id").val();
           $('input:checkbox[name=tags]:checked').each(function(i){
               if(0==i){
                   spCodesTemp = $(this).val();
               }else{
                   spCodesTemp += (","+$(this).val());
               }
           });
           $.ajax({
               type: 'post',
               data: {"userid":usersid,"tags":spCodesTemp},
               url: $("#tagsdiv").attr('_href'),
               dataType: 'text',
               success: function (data) {
                   if(data=='ok'){
                       alert('添加成功');
                       layer.closeAll();
                   }else{
                       alert('添加失败');
                       layer.closeAll();
                   }
               }
           })
       })
   }
    function allcheck(){
        $('table input:checkbox').each(function() {
            $(this).attr('checked', true);
        });
    }
    /*添加多个黑名单*/
    function morebackname(){
        layer.open({
            type: 1,
            skin: 'layui-layer-yuan', //样式类名
            closeBtn: 1, //不显示关闭按钮
            shadeClose: true, //开启遮罩关闭
            shade: [0.5],
            area: '180px',
            title: "加入黑名单",
            content: $('#backdiv')
        });
        $('table input:checkbox[name=tg]:checked').each(function(i){
            if(0==i){
                spCodesTemp = $(this).val();
            }else{
                spCodesTemp += (","+$(this).val());
            }
        });
       $.ajax({
            type: 'post',
            data: {"userid":spCodesTemp},
            url: $("#moreback").attr('_href'),
            dataType: 'text',
            success: function (data) {
                if(data=='ok'){
                    alert('添加成功');
                    layer.closeAll();
                }else{
                    alert('添加失败');
                    layer.closeAll();
                }
            }
        })

    }
    function moretags(){
        layer.open({
            type: 1,
            skin: 'layui-layer-yuan', //样式类名
            closeBtn: 1, //不显示关闭按钮
            shadeClose: true, //开启遮罩关闭
            shade: [0.5],
            area: '180px',
            title: "添加标签",
            content: $('#tagsdiv')
        });
        $("#submit_tags").click(function () {
            $('table input:checkbox[name=tg]:checked').each(function(i){
                if(0==i){
                    spCodesTemp = $(this).val();
                }else{
                    spCodesTemp += (","+$(this).val());
                }
            });
            $('input:checkbox[name=tags]:checked').each(function(j){
                if(0==j){
                    t = $(this).val();
                }else{
                    t += (","+$(this).val());
                }
            });

            $.ajax({
                type: 'post',
                data: {"userid":spCodesTemp,"tag":t},
                url: $("#moretags").attr('_href'),
                dataType: 'text',
                success: function (data) {
                    if(data=='ok'){
                        alert('添加成功');
                        layer.closeAll();
                    }else{
                        alert('添加失败');
                        layer.closeAll();
                    }
                }
            })
        });

    }
    /*搜索*/
    $("#shousuo").click(function(){
        var value =$("#seach").val();
        var url ="<?php echo U('/Admin/Usercenter/Usercenter/index',array('key'=>'USERSEACH','value'=>'seachs'));?>";
        var url =  url.replace("seachs",value);
        window.location.href=url;
    });

    function stopPropagation(e) {
        e = e || window.event;
        if(e.stopPropagation) { //W3C阻止冒泡方法
            e.stopPropagation();
        } else {
            e.cancelBubble = true; //IE阻止冒泡方法
        }
    }

</script>